<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:c="http://java.sun.com/jsp/jstl/core"
                template="./../template/AdminTemplate.xhtml">

    <ui:define name="contentInsert">
        
        <h3>Stakeholder Categories</h3>
        
        
        <!--Table showing all the categories-->
        <h:form id="deletecategory">
                <p:dataTable value="#{categoryManagerBean.getAllCategories()}" var="o" paginator="true" rows="15"
                                 styleClass="order-table" 
                >
                    
                        <p:column headerText="Description" style="width: 20px">      
                            #{o.description}
                        </p:column>
                        
                        <p:column headerText="Type" style="width: 20px">      
                            #{o.type}
                        </p:column>
                    
                        <p:column  style="width: 30px">      
                                <p:commandButton   value="Delete Category" onclick="if (!confirm('Are you sure you want to delete this ctegory?')) return false"
                                     action="#{categoryManagerBean.removeCategory(o)}" ajax="false">
                                </p:commandButton>
                        </p:column>
                    
                    
                </p:dataTable>
        </h:form>
        
        <br/>
        <br/>
        <br/>

        <h3>Add A New Category</h3>
        <h:form id="addcategory">
                        
                        <p:ajaxStatus style="width:16px;height:16px;">
                            <f:facet name="start">
                                <h:graphicImage value="http://www.primefaces.org:8080/showcase/design/ajaxloading.gif" />
                            </f:facet>
                            <f:facet name="complete">
                                <h:outputText value="" />
                            </f:facet>
                        </p:ajaxStatus>
                        <p:messages />
            
                        <h:panelGrid columns="3">
                            <h:outputLabel for="description" value="Category Description:"/>
                            <p:inputText required="true" requiredMessage="A Description name is requied!"
                                         id="description" value="#{categoryManagerBean.inputDescription}"/>
                            <p:message for="description"/>
                            
                            <h:outputLabel for="type" value="Category Type: "/>
                            <h:selectOneMenu value="#{categoryManagerBean.inputCategoryType}">
                                <f:selectItems value="#{categoryManagerBean.categoryTypeList}" var="c" itemLabel="#{c}" itemValue="#{c}" />
                            </h:selectOneMenu>
                        </h:panelGrid>
            
            <p:commandButton value="Add New Category" onclick="if (!confirm('Are you sure you want to add this new Category?')) return false"
                                         action="#{categoryManagerBean.addNewCategory()}" ajax="false"
                                    />
        </h:form>
        <br/>
        <br/>
        <br/>



    </ui:define>
</ui:composition>

